package com.supor.aiot.mine.api;

import com.android.baseconfig.base.BaseApiResult;
import com.android.baseconfig.base.BaseRetrofit;
import com.supor.aiot.mine.bean.RecipeApplyBean;

import java.util.List;

import io.reactivex.rxjava3.core.Observable;

public class RecipeCreateImpl extends BaseRetrofit<RecipeCreateService> implements RecipeCreateService {

    private static RecipeCreateImpl instance;

    public static RecipeCreateImpl getInstance() {
        if (instance == null) {
            instance = new RecipeCreateImpl();
        }
        return instance;
    }

    /**
     *
     * 添加用户食谱创作申请数据
     *
     * @param recipeApplyBean recipeApplyBean
     * @return Observable<BaseApiResult<RecipeApplyBean>>
     */
    @Override
    public Observable<BaseApiResult<RecipeApplyBean>> addRecipeApply(RecipeApplyBean recipeApplyBean) {
        return api.addRecipeApply(recipeApplyBean).compose(this.applySchedulers());
    }

    /**
     *
     * 撤销申请
     *
     * @param applyId 创作申请主键
     * @return Observable<BaseApiResult<String>>
     */
    @Override
    public Observable<BaseApiResult<String>> deleteRecipeApply(String applyId) {
        return api.deleteRecipeApply(applyId).compose(this.applySchedulers());
    }

    /**
     *
     * 判断用户是不是已经申请了
     *
     * @return Observable<BaseApiResult<String>>
     */
    @Override
    public Observable<BaseApiResult<String>> getApplyStatus() {
        return api.getApplyStatus().compose(this.applySchedulers());
    }

    /**
     *
     * 查询所有记录，不分页
     *
     * @return Observable<BaseApiResult<List<RecipeApplyBean>>>
     */
    @Override
    public Observable<BaseApiResult<List<RecipeApplyBean>>> getApplyAll() {
        return api.getApplyAll().compose(this.applySchedulers());
    }
}
